home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 30
/
Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso
/
Aminet
/
gfx
/
ifx
/
card_prep.lha
/
Card_prep.ifx
next >
Wrap
Text File
|
1999-02-21
|
8KB
|
335 lines
/*
* $VER: Card_prep.ifx 2.0 (16.2.99)
*
* Tested with IFX 1.52, 2.6 and 3.3
*
* This script will crop and/or add a border to the buffer so it
* will have the proper proportions when it eventually gets scaled
* down to a card image for Soliton or REKO card sets. This script
* will also do the scaling for you, if you like.
*
* IMPORTANT!
* Make sure the image you plan to use this
* script with is set to the correct aspect.
*
* If you want the image cropped, use the box region tool before you
* run this script to define the area of the image you wish to keep.
* The script will then find the smallest card-shaped area which can
* contain the area you have defined.
*
* The Reko cardset setting assumes you will be viewing the finished cards
* on a PAL display. If this is not the case then select "Custom" cardset
* type, set the width and height to 88 and 130 respectively, and choose
* the correct display type.
*
* I GUARANTEE NOTHING. YOU USE THIS SCRIPT AT YOUR OWN RISK!
*
* Do with it and edit it as you like.
*
*
* **** Written by Cary Driscoll ****
*
* **** cdriscol@flash.net ****
*/
OPTIONS RESULTS
getversion
PARSE VAR RESULT name ifx_version date
getmain
IF ifx_version < 2 THEN DO
IF result = "" THEN DO
RequestNotify "No image Loaded!"
EXIT
END
END
ELSE DO
IF rc ~= 0 THEN DO
RequestNotify "No image Loaded!"
EXIT
END
END
Parse var result name picwidth picheight depth Xaspect Yaspect .
getregionarea
IF rc ~= 0 THEN DO
left = 0
top = 0
width = picwidth
height = picheight
END
ELSE DO
PARSE VAR RESULT left top width height
END
Region Full
/* Retrieve previous values from the environment */
CardSet = GETCLIP('Card_CardSet')
Display = GETCLIP('Card_Display')
Hires = GETCLIP('Card_Hires')
Lace = GETCLIP('Card_Lace')
Card_Width = GETCLIP('Card_X')
Card_Height = GETCLIP('Card_Y')
Sharp = GETCLIP('Card_Sharp')
Sharp_N = GETCLIP('Card_Sharp_N')
Con = GETCLIP('Card_Con')
Con_N = GETCLIP('Card_Con_N')
/* If empty values are returned from the environment, set these to the following: */
IF CardSet = '' THEN CardSet = 0 /* Defaults to REKO */
IF Display = '' THEN Display = 0 /* "Custom" defaults to NTSC */
IF Hires = '' THEN Hires = 0
IF Lace = '' THEN Lace = 0
IF Card_Width = '' THEN Card_Width = 88 /* Default custom card width */
IF Card_Height = '' THEN Card_Height = 130 /* Default custom card height */
IF Sharp = '' THEN Sharp = 1
IF Sharp_N = '' THEN Sharp_N = 40 /* Default sharpening */
IF Con = '' THEN Con = 1
IF Con_N = '' THEN Con_N = 10 /* Default contrast */
IF ifx_version < 2 THEN DO
Gadget.1 = 'C/60/19//2/REKO/Custom'
ComplexRequest '"Cardset Type"' 1 Gadget 220 55
IF rc ~= 0 THEN EXIT
END
ELSE DO
Gadget.1 = 'CYCLE LE=75 TE=5 LB=Game: IN='||CardSet||' CH=REKO/Custom'
Gadget.2 = END
NewComplexRequest '"Cardset Type"' Gadget 205 24
IF rc ~= 0 THEN EXIT
END
CardSet = result.1
IF CardSet = 0 THEN DO
Display = 1
Hires = 0
Lace = 0
Card_Width = 88
Card_Height = 130
Card_Xaspect = 12
Card_Yaspect = 11
END
ELSE DO
IF ifx_version < 2 THEN DO
Gadget.1 = 'C/85/15/Display:/3/NTSC/PAL/VGA'
Gadget.2 = 'X/170/32/Hires?/'Hires
Gadget.3 = 'X/170/49/Lace?/'Lace
Gadget.4 = 'J/110/30/40/Card Width/'||Card_Width
Gadget.5 = 'J/110/47/40/Card Height/'||Card_Height
ComplexRequest '"Custom Card Setting"' 5 Gadget 273 82
IF rc ~= 0 THEN EXIT
END
ELSE DO
Gadget.1 = 'CYCLE LE=110 TE=5 LB=Display: IN='||Display||' CH=NTSC/PAL/VGA'
Gadget.2 = 'CHECK LE=170 TE=22 LB=Hires? IN='||Hires
Gadget.3 = 'CHECK LE=170 TE=39 LB=Lace? IN='||Lace
Gadget.4 = 'INTEGER LE=110 TE=20 WD=40 LB="Card Width" IN='||Card_Width
Gadget.5 = 'INTEGER LE=110 TE=37 WD=40 LB="Card Height" IN='||Card_Height
Gadget.6 = END
NewComplexRequest '"Custom Card Settings"' Gadget 273 57
IF rc ~= 0 THEN EXIT
END
Display = result.1
Hires = result.2
Lace = result.3
Card_Width = result.4
Card_Height = result.5
IF Display = 0 THEN DO /* NTSC */
IF Hires = Lace THEN DO
Card_Xaspect = 11
Card_Yaspect = 13
END
ELSE DO
IF Hires = 1 THEN DO
Card_Xaspect = 11
Card_Yaspect = 26
END
ELSE DO
Card_Xaspect = 22
Card_Yaspect = 13
END
END
END
IF Display = 1 THEN DO /* PAL */
IF Hires = Lace THEN DO
Card_Xaspect = 12
Card_Yaspect = 11
END
ELSE DO
IF Hires = 1 THEN DO
Card_Xaspect = 6
Card_Yaspect = 11
END
ELSE DO
Card_Xaspect = 24
Card_Yaspect = 11
END
END
END
IF Display = 2 THEN DO /* VGA */
IF Hires = Lace THEN DO
Card_Xaspect = 1
Card_Yaspect = 1
END
ELSE DO
IF Hires = 1 THEN DO
Card_Xaspect = 1
Card_Yaspect = 2
END
ELSE DO
Card_Xaspect = 2
Card_Yaspect = 1
END
END
END
END
/* Store the given values in the environment for the next run */
CALL SETCLIP('Card_CardSet',CardSet)
CALL SETCLIP('Card_Display',Display)
CALL SETCLIP('Card_Hires',Hires)
CALL SETCLIP('Card_Lace',Lace)
CALL SETCLIP('Card_X',Card_Width)
CALL SETCLIP('Card_Y',Card_Height)
Ratio = ((Card_Height * Card_Yaspect) / (Card_Width * Card_Xaspect)) * (Xaspect / Yaspect)
H = height
W = width
TestH = W * Ratio
IF height < TestH THEN H = TestH
ELSE W = H % Ratio
C = 0
IF H > picheight THEN C = 1
IF W > picwidth THEN C = 2
Redraw Off
IF C = 0 THEN DO
IF H = height THEN DO
L = left - (W - width) % 2
IF L < 0 THEN L = 0
IF L + W > picwidth THEN L = picwidth - W
Crop L top W H
END
ELSE DO
T = top - (H - height) % 2
IF T < 0 THEN T = 0
IF T + H > picheight THEN T = picheight - H
Crop left T W H
END
END
IF C = 1 THEN DO
Scale picwidth H BORDER
Crop left 0 W H
END
IF C = 2 THEN DO
Scale W picheight BORDER
Crop 0 top W H
END
Redraw On
IF C ~= 0 THEN DO
RequestResponse "Do you want ""zoom"" borders?"
IF rc = 0 THEN DO
RequestResponse "Are you sure? This could take a while."
IF rc = 0 THEN DO
Redraw Off
Undo Off
IF C = 1 THEN DO
B = (H - picheight) % 2
Scissors
Box 0 B W 1
DO x = 0 to B
Scale W+2*x 1
Point W%2-x B-x
END
B = B + picheight - 1
Scissors
Box 0 B W 1
DO x = 0 to H-B
Scale W+2*x 1
Point W%2-x B+x
END
KillBrush
END
ELSE DO
B = (W - picwidth) % 2
Scissors
Box B 0 1 H
DO x = 0 to B
Scale 1 H+2*x
Point B-x H%2-x
END
B = B + picwidth - 1
Scissors
Box B 0 1 H
DO x = 0 to W-B
Scale 1 H+2*x
Point B+x H%2-x
END
KillBrush
END
Undo On
Redraw On
END
END
END
RequestResponse "Do you want this image scaled?"
IF rc ~= 0 THEN EXIT
SetAspect Card_Xaspect Card_Yaspect
Scale Card_Width Card_Height
IF ifx_version < 2 THEN DO
Gadget.1 = 'X/15/15/Sharpen?/'Sharp
Gadget.2 = 'X/15/32/Contrast?/'Con
Gadget.3 = 'J/220/14/45/0 to 255 /'Sharp_N
Gadget.4 = 'J/220/31/45/-127 to +127 /'Con_N
ComplexRequest '"Sharpen and Contrast"' 4 Gadget 290 65
IF rc ~= 0 THEN EXIT
END
ELSE DO
Gadget.1 = 'CHECK LE=15 TE=5 LB=Sharpen? IN='||Sharp
Gadget.2 = 'CHECK LE=15 TE=22 LB=Contrast? IN='||Con
Gadget.3 = 'INTEGER LE=225 TE=4 WD=45 LB="0 to 255 " IN='||Sharp_N
Gadget.4 = 'INTEGER LE=225 TE=21 WD=45 LB="-127 to +127 " IN='||Con_N
Gadget.5 = END
NewComplexRequest '"Sharpen and Contrast"' Gadget 290 40
IF rc ~= 0 THEN EXIT
END
Sharp = result.1
Con = result.2
Sharp_N = result.3
Con_N = result.4
IF Sharp_N < 0 THEN Sharp_N = 0
IF Sharp_N > 255 THEN Sharp_N = 255
IF Con_N < -127 THEN Con_N = -127
IF Con_N > 127 THEN Con_N = 127
IF Con = 1 THEN Contrast Con_N
IF Sharp = 1 THEN Sharpen Sharp_N
CALL SETCLIP('Card_Sharp',Sharp)
CALL SETCLIP('Card_Sharp_N',Sharp_N)
CALL SETCLIP('Card_Con',Con)
CALL SETCLIP('Card_Con_N',Con_N)
EXIT